/**
 * @file AgentDefs.h
 * @author w (w@163.com)
 * @brief 日志宏定义
 * @version 0.1
 * @date 2024-04-26
 *
 * @copyright Copyright (c) 2024 xxxx公司
 *
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-04-26 <td>v1.0     <td>chen     <td>内容
 * </table>
 */
#ifndef AGENT_DEFS_H
#define AGENT_DEFS_H

#include <string>
#include <ExperiDefs.h>

/**
 * @brief 获取文件名宏
 *
 * @details
 */
#ifndef __FILENAME__
#define __FILENAME__                                         \
	(strrchr(__FILE__, '\\') ? (strrchr(__FILE__, '\\') + 1) \
	                         : ((strrchr(__FILE__, '/')) ? (strrchr(__FILE__, '/') + 1) : (__FILE__)))
#endif // __FILENAME__

/**
 * @brief 文件和行号宏
 *
 * @details
 */
#ifndef __COMMON_LOG__
#define __COMMON_LOG__ " [" << __FILENAME__ << ", " << __LINE__ << "]"
#endif // __COMMON_LOG__

/**
 * @brief 记录Debug日志
 *
 * @details
 */
#ifndef RECORD_DEBUG_LOG
#define RECORD_DEBUG_LOG(msg)                                                                \
	{                                                                                        \
		std::stringstream ss;                                                                \
		ss << msg << __COMMON_LOG__;                                                         \
		VCommunication::Instance()->WriteLog(ExperiLogLevel::Debug, ss.str(), __FUNCTION__); \
	}
#endif

/**
 * @brief 记录Info日志
 *
 * @details
 */
#ifndef RECORD_INFO_LOG
#define RECORD_INFO_LOG(msg)                                                                \
	{                                                                                       \
		std::stringstream ss;                                                               \
		ss << msg << __COMMON_LOG__;                                                        \
		VCommunication::Instance()->WriteLog(ExperiLogLevel::Info, ss.str(), __FUNCTION__); \
	}
#endif

/**
 * @brief 记录Warning日志
 *
 * @details
 */
#ifndef RECORD_WARNING_LOG
#define RECORD_WARNING_LOG(msg)                                                                \
	{                                                                                          \
		std::stringstream ss;                                                                  \
		ss << msg << __COMMON_LOG__;                                                           \
		VCommunication::Instance()->WriteLog(ExperiLogLevel::Warning, ss.str(), __FUNCTION__); \
	}
#endif

/**
 * @brief 记录Err日志
 *
 * @details
 */
#ifndef RECORD_ERR_LOG
#define RECORD_ERR_LOG(msg)                                                                  \
	{                                                                                        \
		std::stringstream ss;                                                                \
		ss << msg << __COMMON_LOG__;                                                         \
		VCommunication::Instance()->WriteLog(ExperiLogLevel::Error, ss.str(), __FUNCTION__); \
	}
#endif

/**
 * @brief 记录Fatal日志
 *
 * @details
 */
#ifndef RECORD_FATAL_LOG
#define RECORD_FATAL_LOG(msg)                                                                \
	{                                                                                        \
		std::stringstream ss;                                                                \
		ss << msg << __COMMON_LOG__;                                                         \
		VCommunication::Instance()->WriteLog(ExperiLogLevel::Fatal, ss.str(), __FUNCTION__); \
	}
#endif

#endif // AGENT_DEFS_H
